import { Injectable } from '@angular/core';
import { NavHeaderService } from '@global/layout/default/nav-header/nav-header.service';

import { Environment } from 'environments/environment';
@Injectable({
  providedIn: 'root'
})
export class BaseUrlService {
  static productLineCode = 'FCS';
  static standardProductTypeCode = 'FCS';
  static fcsModel = 'ifcs';
  static ossModel = 'oss';
  static vpcModel = 'vpc';
  static apigModel = 'apig';
  static cirModel = 'cir';
  constructor(private navHeaderService: NavHeaderService) { }

  /**
   * 获取后端请求地址
   * @returns
   * @memberof BaseUrlService
   */
  baseUrl(region?) {

    let prodUrl = this.navHeaderService.getFullPath(BaseUrlService.fcsModel, region);
    let devUrl = Environment.application.serviceAPI + (region ? `/regionsvc-${region}/ifcs` : '/regionsvc-cn-north-3/ifcs');
    return Environment.production ? prodUrl : devUrl;
  }

  ossBaseUrl(region?) {
    let prodUrl = this.navHeaderService.getFullPath(BaseUrlService.ossModel, region);
    let devUrl = Environment.application.serviceAPI + (region ? `/regionsvc-${region}/oss` : '/regionsvc-cn-north-3/oss');
    return Environment.production ? prodUrl : devUrl;
  }

  vpcBaseUrl(region?) {
    let prodUrl = this.navHeaderService.getFullPath(BaseUrlService.vpcModel, region);
    let devUrl = Environment.application.serviceAPI + (region ? `/regionsvc-${region}/vpc` : '/regionsvc-cn-north-3/vpc');
    return Environment.production ? prodUrl : devUrl;
  }

  apigBaseUrl(region?) {
    let prodUrl = this.navHeaderService.getFullPath(BaseUrlService.apigModel, region);
    let devUrl = Environment.application.serviceAPI + (region ? `/regionsvc-${region}/apig` : '/regionsvc-cn-north-3/apig');
    return Environment.production ? prodUrl : devUrl;
  }

  cirBaseUrl(region?) {
    let prodUrl = this.navHeaderService.getFullPath(BaseUrlService.cirModel, region);
    let devUrl = Environment.application.serviceAPI + (region ? `/regionsvc-${region}/cir` : '/regionsvc-cn-north-3/cir');
    return Environment.production ? prodUrl : devUrl;
  }
}
